import request from '@/router/axios';
import {baseUrl} from '@/config/env';

export const list = (data) => {
    return request({
            url: baseUrl + '/actProcessModel/page',
            method: 'get',
            params: data
        }
    )
}
export const add = (data) => {
    return request({
            url: baseUrl + '/actProcessModel/add',
            method: 'post',
            data: data
        }
    )
}

export const updateById = (id, data, index) => {
    return request({
            url: baseUrl + '/actProcessModel/updateById',
            method: 'put',
            data: data
        }
    )
}
export const deleteById = (id) => {
    return request({
            url: baseUrl + '/actProcessModel/deleteById/' + id,
            method: 'delete',
        }
    )
}
export const getById = (id) => {
    return request({
            url: baseUrl + '/actProcessModel/getById/' + id,
            method: 'get',
        }
    )
}

export const getActModelConfigDetail = (id) => {
    return request({
            url: baseUrl + '/actProcessModel/getActModelConfigDetail/' + id,
            method: 'get',
        }
    )
}

export const saveModelEditorSource = (id, data) => {
    return request({
            url: baseUrl + '/actProcessModel/saveModelEditorSource/' + id,
            method: 'post',
            data: data
        }
    )
}

/**
 * 部署流程模型
 * @param id
 * @returns {AxiosPromise}
 */
export const deploymentModel = (id) => {
    return request({
            url: baseUrl + '/actProcessModel/deploymentModel/' + id,
            method: 'get',
        }
    )
}
/**
 * 获取模型配置
 * @param id
 * @returns {AxiosPromise}
 */
export const getModelConfig = (id) => {
    return request({
            url: baseUrl + '/actProcessModel/getModelConfig/' + id,
            method: 'get',
        }
    )
}
/**
 * 获取模型配置
 * @param id
 * @returns {AxiosPromise}
 */
export const getAllGroupModels = () => {
    return request({
            url: baseUrl + '/actProcessModel/getAllGroupModels',
            method: 'get',
        }
    )
}

const modelApi = {
    list,
    getById,
    getModelConfig,
    getAllGroupModels
}
export default modelApi
